package com.example.owner.bean.impl;

import com.example.owner.aop.ProductBean;
import io.micronaut.cache.annotation.Cacheable;
import io.micronaut.context.annotation.Parameter;
import jakarta.annotation.PreDestroy;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@ProductBean
public class Product {

    private final String productName;
    private boolean active = false;

    public Product(@Parameter String productName) { // (2)
        this.productName = productName;
    }

    public String getProductName() {
        return productName;
    }



    @Cacheable
    public boolean isActive() {
        return active;
    }

    public void setActive(boolean active) {
        log.info("set active to " + active);
        this.active = active;
    }

    @PreDestroy
    void disable() {
        log.info("disable to 1 " + active);
        active = false;

        log.info("disable to 2 " + active);
    }
}
